package com.xiaoyuanxing.demo.mapper;

import com.github.pagehelper.Page;
import com.xiaoyuanxing.demo.entity.Talk;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/*
 **@author LuoShengYing
 **@date 2021/5/28
 */
@Mapper
public interface TalkMapper {

    // 返回数据库中的Talks数据
    @Select("select * from `talk`  order by `createdTime` DESC")
    Page<Talk> selectAllTalks();

    // 新建Talk数据
    @Insert("insert `talk` set " +
            "`openID` = #{openID}, `title` = #{title}, `createdTime` = #{createdTime}, " +
            "`tag1` = #{tag1}, `tag2` = #{tag2}, `tag3` = #{tag3}, `content` = #{content}")
    boolean insertTalk(Talk talk);

    // 删除Talk数据ByTalkID
    @Delete("delete from `talk` where `talkID` = #{talkID}")
    boolean deleteTalk(int talkID);
}
